import request from '../request'

// 获得所有权限列表
export function getAllUserRightsApi (type) {
  return request({
    method: 'get',
    url: 'rights/' + type
  })
}

// 获取角色列表
export function getAllRoleInfoApi () {
  return request({
    method: 'get',
    url: 'roles'
  })
}
// 根据id删除角色权限
export function delUserRollApi (roleId, rightId) {
  return request({
    method: 'delete',
    url: `roles/${roleId}/rights/${rightId}`
  })
}
// 分配用户角色
export function postUserRollApi (id, data) {
  return request({
    method: 'post',
    url: `roles/${id}/rights`,
    data
  })
}
// 添加角色信息
export function addtRoleInfoApi (data) {
  return request({
    method: 'post',
    url: 'roles',
    data
  })
}
// 根据id获得当前角色信息
export function getRoleInfoApi (id) {
  return request({
    method: 'get',
    url: `roles/${id}/`
  })
}
// 修改角色信息 data:{roleName:roleName,roleDesc:roleDesc}
export function changeRoleInfoApi (id, data) {
  return request({
    method: 'put',
    url: `roles/${id}/`,
    data
  })
}
// 删除角色信息
export function delRoleInfoApi (id) {
  return request({
    method: 'delete',
    url: `roles/${id}/`
  })
}
